package com.yantong.constant;

import java.util.*;

/**
 * 支付状态
 * @author kanghaixin
 * @date 2018/9/7.15:59
 */
public enum PayStatus {
    NO_PAY(0, "未支付"),
    PAYING(1, "支付中"),
    PAY_SUCCESS(2, "支付完成"),
    PAY_FAIL(3, "订单取消"),
    PAY_AGENT_APPLY(4, "代付申请"),
    PAYING_AGENT(5, "代付中"),
    PAY_SUCCESS_AGENT(6, "代付成功"),
    PAY_FAIL_AGENT(7, "代付失败"),
    REFUND_APPLY(8, "退款申请"),
    REFUNDING(9, "退款中"),
    REFUND_SUCCESS(10, "退款成功"),
    REFUND_FAIL(11, "退款失败")
    ;

    private int code;
    private String name;


    public static List<Map<String, Object>> getPayStatusList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (PayStatus status: PayStatus.values()) {
            Map<String,Object> item = new HashMap<>();
            item.put("name", status.getName());
            item.put("code", status.getCode());
            list.add(item);
        }
        return list;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    PayStatus(int code, String name) {
        this.code = code;
        this.name = name;
    }

    private static Map<Integer, String> all= new HashMap<>();
    static{
        for(PayStatus payStatus: EnumSet.allOf(PayStatus.class)){
            all.put(payStatus.code, payStatus.name);
        }
    }
    public static String get(Integer code){
        return all.get(code);
    }
}
